using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using JGSY.CMS.LowCode.Platform.Infrastructure.Configuration.ServiceModules;
using JGSY.CMS.LowCode.Platform.Infrastructure.Extensions;

namespace JGSY.CMS.LowCode.Platform.Infrastructure.Configuration.MiddlewareModules.Modules
{
    /// <summary>
    /// 性能优化中间件模块
    /// 包含性能监控、缓存等性能优化中间件
    /// </summary>
    public class PerformanceMiddlewareModule : IMiddlewareModule
    {
        public string ModuleName => "性能优化中间件";
        public int Priority => 2;
        public bool EnableInDevelopment => true;
        public bool EnableInProduction => true;
        public bool EnableInFastMode => true;
        public ModulePermission RequiredPermission => ModulePermission.PerformanceServices;
        public bool IsCriticalModule => false; // 非关键中间件

        public void ConfigureMiddleware(WebApplication app, IConfiguration configuration)
        {
            // 使用高级性能优化中间件（包含性能监控、缓存等）
            app.UseAdvancedPerformanceOptimization();
        }

        public void ConfigureMinimalMiddleware(WebApplication app, IConfiguration configuration)
        {
            // 精简性能优化功能 - 使用基本优化
            app.UseBasicPerformanceOptimization();
        }

        public bool ValidateConfiguration(IConfiguration configuration)
        {
            // 性能中间件可以使用默认配置
            return true;
        }
    }
}
